package com.donger.common.core.annotation;

import com.donger.common.core.validator.customrule.IdCardValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * IdCard
 * 这是自定义的validator校验器。用来检查字符串是否是身份证
 * 校验器实现参考{@link IdCardValidator}
 * <h2>使用示例</h2>
 * <pre>
 *     在使用字段上，添加如下注解，即可校验当前字符串包含规则
 *     &#064;IdCard
 *     &#064;IdCard(message="身份证不符合规范")
 * </pre>
 * @author xyx
 * @date 2020-05-28 10:15
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(
        validatedBy = {IdCardValidator.class}
)
public @interface IdCard {

    String message() default "身份证校验失败";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
